<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-cascades"></i> 订单列表
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-select v-model="query.address" placeholder="订单状态" class="handle-select mr10">
                    <el-option key="1" label="待发货" value="待发货"></el-option>
                    <el-option key="2" label="待收货" value="待收货"></el-option>
                    <el-option key="3" label="待支付" value="待支付"></el-option>
                    <el-option key="4" label="已完成" value="已完成"></el-option>
                    <el-option key="5" label="已取消" value="已取消"></el-option>
                </el-select>
                <el-input v-model="query.name" placeholder="订单编号" class="handle-input mr10"></el-input>
                <div class="handle-date mr10">
                    <el-date-picker
                        v-model="value1"
                        type="datetimerange"
                        range-separator="至"
                        start-placeholder="订单开始日期"
                        end-placeholder="订单结束日期"
                    ></el-date-picker>
                </div>
                <el-input v-model="query.name" placeholder="用户ID" class="handle-input mr10"></el-input>
                <el-input v-model="query.name" placeholder="用户昵称" class="handle-input mr10"></el-input>
                <el-input v-model="query.name" placeholder="用户电话" class="handle-input mr10"></el-input>
                <el-input v-model="query.name" placeholder="收货人姓名" class="handle-input mr10"></el-input>
                <el-input v-model="query.name" placeholder="收货人手机号" class="handle-input mr10"></el-input>
                <el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
            </div>
            <el-table
                :data="tableData"
                border
                class="table"
                ref="multipleTable"
                header-cell-class-name="table-header"
                @selection-change="handleSelectionChange"
            >
                <el-table-column type="selection" width="55" align="center"></el-table-column>
                <el-table-column prop="id" label="商品编号" align="center"></el-table-column>
                <el-table-column prop="name" label="商品名称"></el-table-column>
                <el-table-column prop="name" label="商品分类"></el-table-column>
                <el-table-column prop="name" label="价格" align="center"></el-table-column>
                <el-table-column prop="name" label="销量" align="center"></el-table-column>
                <el-table-column prop="name" label="发布人" align="center"></el-table-column>
                <el-table-column prop="name" label="发布位置" align="center"></el-table-column>
                <el-table-column prop="name" label="添加时间" align="center"></el-table-column>
                <el-table-column prop="name" label="更新时间" align="center"></el-table-column>
                <el-table-column prop="name" label="交易类型" align="center"></el-table-column>
                <el-table-column label="商品状态" align="center">
                    <template slot-scope="scope">
                        <el-switch
                            :value="scope.row.state==='成功'?true:(scope.row.state==='失败'?false:'')"
                            active-color="#13ce66"
                            inactive-color="#909399"
                        ></el-switch>
                    </template>
                </el-table-column>

                <el-table-column label="操作" width="180" align="center">
                    <template slot-scope="scope">
                        <el-button @click="handleDetail(scope.$index, scope.row)">详情</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!-- tabel分页 -->
            <div class="pagination">
                <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page.sync="currentPage2"
                    :page-sizes="[10, 20, 30, 50]"
                    :page-size="10"
                    layout="sizes, prev, pager, next"
                    :total="pageTotal"
                ></el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import { fetchData } from '../../api/index';
export default {
  name: 'OrderList',
  data() {
    return {
      query: {
        address: '',
        name: '',
        pageIndex: 1,
        pageSize: 10
      },
      tableData: [],
      multipleSelection: [],
      delList: [],
      TakeOff: false,
      pageTotal: 0,
      form: {},
      idx: -1,
      id: -1
    }
  },
  created() {
    this.getData()
  },
  methods: {
    // 获取 easy-mock 的模拟数据
    getData() {
      fetchData(this.query).then(res => {
        console.log(res);
        this.tableData = res.list;
        this.pageTotal = res.pageTotal || 50;
      });
    },
    handleDetail() {
      this.$router.push('orderDetails')
    }
  }
}
</script>

<style  scoped>
.handle-box {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.handle-select {
    width: 120px;
}

.handle-input {
    width: 200px;
    display: inline-block;
}
.handle-date {
    display: inline-block;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
</style>